<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

    // 需求:点击提交按钮 => 从输入框中 依次取 姓名 密码 手机号 邮箱 存储到对象中


    var user = "a123123";
    var pwd = "123123";
    var phone = "17386141517";
    var email = "1272071495@qq.com";

    // ES5 
    var data = {
        // 键名: 键值
        user:user, 
        pwd:pwd,
        phone:phone,
        email:email,
    }
    console.log(data);

    // ES5 对象中函数的写法
    var zhang = {
        name:"张三",
        age:18,
        say:function(){
            console.log(this.name,this.age);
        }
    }

    // -------------------------------------------

    // ES6 对象的简写
    // (1) 键名和键值对应的变量名相同时,可以简写
    // (2) 函数也可以简写  省略 :function

    var data = {user,pwd,phone,email};
    console.log(data);

    var zhang = {
        name:"张三",
        age:18,
        say(){
            console.log(this);
            console.log(this.name,this.age);
        }
    }

    zhang.say();


   
    


    
</script>
</html>